part of utils;

/// 存放一些扩展的组件。

/// 标题字体。
class TitleText extends Text {
  final String text;
  const TitleText(
    this.text, {
    Key? key,
    bool? softWrap,
  }) : super(
          key: key,
          text,
          softWrap: softWrap ?? false,
          style: const TextStyle(
            fontSize: 18,
            fontWeight: FontWeight.bold,
          ),
        );
}

/// 强调字体
class StrongText extends Text {
  final String text;
  StrongText(
    this.text, {
    Key? key,
    double? size,
    Color? color,
    bool? softWrap,
  }) : super(
          key: key,
          text,
          softWrap: false,
          style: TextStyle(
            fontSize: size,
            color: color,
            fontWeight: FontWeight.bold,
          ),
        );
}

/// 卡片容器 具有阴影效果
class CardContainer extends Container {
  CardContainer({
    Key? key,
    Widget? child,
    double? width,
    double? height,
    Color? backgroundColor,
    BoxConstraints? constraints,
    EdgeInsetsGeometry? margin,
    EdgeInsetsGeometry? padding,
    double? opacity,
  }) : super(
          key: key,
          width: width,
          height: height,
          margin: margin,
          padding: padding,
          constraints: constraints,
          decoration: BoxDecoration(
            border: Border.all(color: lightColor.withOpacity(opacity ?? 0.1)),
            color: Colors.transparent,
            borderRadius: BorderRadius.circular(radius),
            boxShadow: [
              BoxShadow(
                  color: backgroundColor ?? lightColor.withOpacity(opacity ?? 0.05), blurRadius: 1, spreadRadius: 1),
            ],
          ),
          child: child,
        );
}

/// 上图下字
/// 菜单图标
class TIconText extends StatelessWidget {
  final String text;
  final Color? color;
  final IconData? icon;
  final void Function()? onTap;
  const TIconText({
    Key? key,
    required this.text,
    required this.icon,
    this.color,
    this.onTap,
  }) : super(key: key);
  @override
  Widget build(BuildContext context) {
    return CardContainer(
      width: boxSize,
      height: boxSize,
      child: InkWell(
          onTap: onTap,
          borderRadius: BorderRadius.circular(radius),
          child: Column(mainAxisAlignment: MainAxisAlignment.center, children: [
            Expanded(flex: 2, child: Icon(icon, size: 28, color: color)),
            Expanded(flex: 1, child: Text(text, style: TextStyle(color: color)))
          ])),
    );
  }
}

class Plate extends StatelessWidget {
  final String tag;
  const Plate({Key? key, this.tag = ''}) : super(key: key);
  @override
  Widget build(BuildContext context) {
    return CardContainer(
      padding: const EdgeInsets.symmetric(horizontal: 5),
      child: SelectableText(
        tag,
        style: const TextStyle(color: Colors.green, fontSize: 13),
      ),
    );
  }
}
